<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<!DOCTYPE HTML>
<html>
  <head>
    
    <title>商品管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    	
	<meta http-equiv="description" content="This is my page">
	
	
	<link href="<%=basePath %>/background/css/layout.css" rel="stylesheet" type="text/css" />
    <link href="<%=basePath %>/background/css/header.css" rel="stylesheet" type="text/css" />
	 <link href="<%=basePath %>/warehouse/css/button.css" rel="stylesheet" type="text/css" />
	
  </head>
  
  <body>
  <div id="container">
  <div id="header">
		 <jsp:include page="/background/head.jsp"></jsp:include>
	</div>
  <div id="applicationbar">
		 <jsp:include page="/background/app/appbar.jsp"></jsp:include>
	</div>
  <div id="mainContent">
    <div id="sidebar">

		<jsp:include page="/background/left.jsp"></jsp:include>
	</div>
	
	
	
    <div id="content" >
    
    <div style="border:1px solid #ffffff; border-top-color:#6cb1f1; background-color: #e5f3ff; width: 100%; top: 0px;" >
							查找产品信息
     			<input type="button" value="查看谁有权限" 
     				class="small button orange" onclick="javascript:openUrlForDialog('selectoperatorlimitedAction_background.action?limitedCode=<s:property value="limitedcode"/>')"/>
		<div style="float: right;">
			<a href="goodsexportinfo.jsp">导出产品</a>
     			<a href="preaddgoods_warehouse.action">添加新产品</a>
     		</div>
	</div>
	
	<label>
		<s:fielderror id="errormessage" />
	</label>
    
    <div style=" height: 25px;margin: 15px;">
	     <form id="managegoods_warehouse" name="managegoods_warehouse" onSubmit="return true;" action="managegoods_warehouse.action" method="POST" >
	    	
						  查找产品:<input type="text" class="searchtxt" name="searchStr" size="30" value="<s:property value="searchStr"/>"/>
						  <input style="bottom: 3px;" class="large button blue" type="submit" value="查找" />
					 
		</form> 
	</div>
	
	<div style="width: 100%;padding:0px;float:left;">
	
		<div style="display:inline-block; float:left;width:200px; margin:0; ">
		
			 <div style="border:1px solid #ffffff; border-top-color:#6cb1f1; background-color: #e5f3ff;width:200px; top: 0px;" >
					<a href="managegoodsclass_warehouse.action">产品分类</a>
			</div>
			<div>
				<a href="managegoods_warehouse.action?goodsclassid=0">所有分类</a>
			</div>
			
			<s:iterator id="goodsclassMap" value="goodsclassMap"> 
						<div>
								<a href="managegoods_warehouse.action?goodsclassid=<s:property value="value.id_goodsclass"/>">
								<s:if test="value.parentid_goodsclass == 0">
								--<s:property value="value.name_goodsclass"/>
								</s:if>
								<s:else> 
								----<s:property value="value.name_goodsclass"/>
								</s:else>
								</a>
							</div>
			</s:iterator>
				
		</div>
		<div  style="display:inline-block; float:left;width:780px;top: 0px; margin-top: 0px;" >
			
				<div style="border:1px solid #ffffff; border-top-color:#6cb1f1; background-color: #e5f3ff; width: 100%; float:inherit;" >
						产品列表---
				</div>
				<div id="tradeContaniner" >
				<br/>
					<s:iterator id="goodsList" value="goodsList">
						<div  id="tradeContent" style="margin:5px;border:1px solid #ffffff; border-bottom-color:#b2d5ff;
    border-left-color:#b2d5ff;border-right-color:#b2d5ff;border-top-color:#b2d5ff; ">
							<div style="background-color:#f3f7fc;padding: 0px;top:0px; margin:0px;">
							产品编号:<s:property value="#goodsList.id_goods"/>
							
							<div style="float: right;">
								<font color="red">
										产品价值:<s:property value="goodsSalesReportsMap.get(#goodsList.id_goods).profit"/>
								</font>
								<font color="#c0c0c0">
								<s:property value="goodsSalesReportsMap.get(#goodsList.id_goods).goodssalesnumber"/>个/
								<s:property value="goodsSalesReportsMap.get(#goodsList.id_goods).average"/>日/
															
															
								<s:if test="#goodsList.number_goods == 0">
								已经缺货	
								</s:if>
								<s:else>
								<s:property value="goodsSalesReportsMap.get(#goodsList.id_goods).surplusday"/>天
								</s:else>
								</font>
								<font color="#c0c0c0">重量:<s:property value="#goodsList.kg_goods"/></font>
				     		</div>
				     		
							</div>
							<div style="padding: 0px;top:0px;">
							
											<table bordercolor="#f5f5f5" style="border-collapse:collapse; border-width:1px 0 0 1px; width: 100%;">
												<tr>
													<td width="515" >
													
													
													
													
														<table style=" width: 100%;">
															<tr>
																<td width="62" height="62">
																 	
																<img width="60" height="60" alt="" src="<s:property value="#goodsList.image_goods"/>" />
																
																</td>
																<td width="305">
																
																<a href="#">
																<s:property value="#goodsList.name_goods"/>
																</a>
																
																<s:if test="#goodsList.url_goods != ''">
											   					<a href="<s:property value="#goodsList.url_goods"/>" target="_blank">
											   						<img src="<%=basePath %>/warehouse/image/magnifier.jpg"></img>
											   					</a>
											   					</s:if>
																</td>
																
																<td width="105" align="center">
																
																<p>
																<font color="green">均价:<s:property value="#goodsList.average_goods"/></font>
																</p><p>
																<font color="#c0c0c0">最新价:<s:property value="#goodsList.price_goods"/></font>
																</p>
																</td>
															</tr>
															
														</table>
													
														
													</td>
													
													<td align="center" width="85">
														
														<s:property value="#goodsList.number_goods"/>件
													</td>
													
													<td align="center" width="85"> 
													<s:iterator id="goodsclasslistInfoList" value="goodsclasslistInfoMapList.get(#goodsList.id_goods)" status="stu">   
														   
												            </br>
															<font color="black"><s:property value="#goodsclasslistInfoList.goodsclassname_goodsclass"/>
															</font>
						
													</s:iterator>
													</td>
													
												 
													
													<td align="center" width="85">

														<a class="large button green" href="premodifygoods_warehouse.action?id=<s:property value="#goodsList.id_goods"/>"> 修改 </a>
															
													
													</td>
												</tr>
											</table>
										
							</div>
						</div>
					</s:iterator>
				</div>
				
				<div>
  <div>
						<%
						
						 String url = "managegoods_warehouse.action";//*/
						 int pageSize = (Integer) request.getAttribute("pageSize");
						int beginPageNum =  (Integer) request.getAttribute("beginPageNum");
						int countRow =  (Integer) request.getAttribute("rowNum");
						   int countPage =(countRow-1)/pageSize+1;
						   int currentPage = countPage - (countRow-beginPageNum)/pageSize;
						    
						    int goodsclassid = (Integer) request.getAttribute("goodsclassid");
						    
						    
						 	 
						    
						    String searchstr = (String)request.getParameter("searchStr");//*/
						    if(searchstr != null){
						    	searchstr = java.net.URLDecoder.decode(searchstr, "UTF-8");
						    	searchstr = java.net.URLEncoder.encode(searchstr,"UTF-8");
						    	searchstr = searchstr.replaceAll("%", "%25");
						    }else{
						    	searchstr = "";
						    }
						    
						    if((beginPageNum-pageSize+1) >= 1){%>
					    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum-pageSize) %>&goodsclassid=<%=goodsclassid %>">
									上一页 </a>
					   <% }
						    
						    //beginPageNum =  (pageNum - 1) * pageSize;
							StringBuffer chagePageBuff = new StringBuffer();
							if(countPage >= 2){ 
								int begin = currentPage - 9;
								int end = currentPage + 9;
								
								if(begin < 1){
									begin = 0;
								}
								if(end > countPage){
									end = countPage-1;
								}
								
								
								for(int i=begin;i<countPage;i++){
									
									
									
									
									
									if(beginPageNum == i*pageSize){
										%>
										<%=i+1 %>
										<%
									}else{
										%>
										<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=i*pageSize %>&goodsclassid=<%=goodsclassid %>">
										[<%=i+1 %>] </a>
										<%
									}
									
									if(i > end){
										
										break;
										
									}
								}
							}
							
							if((beginPageNum+pageSize-countRow) < 0){%>
					    	<a href="<%=url %>?searchStr=<%=searchstr %>&beginPageNum=<%=(beginPageNum+pageSize) %>&goodsclassid=<%=goodsclassid %>">
									下一页 </a>
					   		<% }
							if(countPage != 1){%>
				    		<input type="text" size="4" id="goPageNum" name="goPageNum"/> / <%=countPage %> <button onclick="gotoPage();">跳转</button>
					   		<% }
							//*/
							%>
				</div>
  </div>
			</div>
		
	</div>
	
	
	
	</div>
	
  </div>
  
  <div id="footer">
<jsp:include page="/background/tail.jsp"></jsp:include>
	</div>
</div>
  
  
  

  </body>
<script type="text/javascript">


function gotoPage(){
	countPage = <%=countPage %>;
	pageSize = <%=pageSize %>;
	pageNum = document.getElementById("goPageNum").value;

	pageNum = parseInt(pageNum);
	if(pageNum > countPage){
		pageNum = countPage;
	}
	beginPageNum = pageNum * pageSize - pageSize;
	if(beginPageNum < 0){
		beginPageNum = 0;

	}
	if(isNaN(beginPageNum)){
		beginPageNum = 0;
	}
	url = '<%=url %>?searchStr=<%=searchstr %>&beginPageNum=' + beginPageNum + '&goodsclassid=<%=goodsclassid %>';
	//alert(url);
	window.location.href=url;
}

</script>
</html>
